<template>
  <div>
    <h1 class="h1_line" @click="recommend">人气推荐&gt;</h1>

    <div class="recommend_box">
      <div
        class="box"
        v-for="(item, index) in list"
        :key="index"
        v-show="index >= 5 && index <= 8"
        @click="onClickRen(item.id)"
      >
        <img :src="item.pic" alt="" />
        <p>{{ item.name }}</p>
        <p>{{ item.minPrice }}</p>
      </div>
    </div>
  </div>
</template>

<script>
import PATH from "../../router/cons"; //封装路由
export default {
  data() {
    return {
      list: [],
    };
  },
  mounted() {
    this.$API.getStoreList().then((res) => {
      this.list = res.data.data;
      console.log(res);
    });
  },
  methods: {
    recommend() {
      this.$router.push("/Recommend_list");
    },
    onClickRen(id) {
      // console.log('1234');
      this.$router.push({
        path: "/Recommend_detail",
        query: {
          id,
        },
      });
    },
  },
};
</script>

<style lang="scss">
.h1_line {
  width: 100%;
  height: 1rem;
  line-height: 1rem;
  background-color: white;
  text-align: center;
  font-size: 0.4rem;
  margin-top: 0.3rem;
}
.recommend_box {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  .box {
    width: 48%;
    height: 300px;
    background: white;

    img {
      width: 100%;
      height: 80%;
    }
  }
}
</style>